def addDigits(self, num):
  def getNext(n):
    total=0
    while n!=0:
      total+=n%10
      n/=10
    return total
  result=num
  while result/10>0:
    result=getNext(num)
    num/=10
  return result
